package com.cglib;

import java.util.Calendar;
import java.util.Date;

public class DateIntConvert implements net.sf.cglib.core.Converter {

	public Object convert(Object value, Class target, Object context) {
		System.out.println(value.getClass() + " " + value); // from类中的value对象
		System.out.println(target); // to类中的定义的参数对象
		System.out.println(context.getClass() + " " + context); // String对象,具体的方法名
		if (target.isAssignableFrom(Date.class)) {
			Calendar c = Calendar.getInstance();
			c.add(Calendar.YEAR, (Integer) value * -1);
			return c.getTime();
		} else {
			return value;
		}
	}

}
